import os
import re
import urllib
from BeautifulSoup import BeautifulSoup
import sys

newfile = ''

##for line in open('insert_discs', 'r').readlines():
##    newfile += "%s);\n" % re.sub('(?<=")([A-Za-z]+ - )', '', line.replace('\n', ''))
##
##file = open('correct_discs', 'w')
##file.write(newfile)
##file.close()

site = 'https://webapps.uc.edu/onestop/learningopp/college.asp'
fields = {
    "TERMCODE": "11A"
}
data = urllib.urlencode(fields,doseq=True)
college_url = urllib.urlopen(site, data)
college_soup = BeautifulSoup(college_url.read()).findAll('option')
for option in college_soup:
##    print str(option["value"])
    if option["value"] != "-1":
        subSite = "https://webapps.uc.edu/onestop/learningopp/discipline.asp"
        subFields = {        
            "COLLEGE_ID": "+%s+" % option["value"]
        }
        subData = urllib.urlencode(subFields,doseq=True)
        discipline_url = urllib.urlopen(subSite, subData)
        print discipline_url.read()
        sys.exit(1)
